// SCENARIO SCRIPT

// This is the special script for your entire scenario. It contains
// special encounters and code accessable from anywhere in the scenario. it also
// contains the code that initializes important special things in the
// scenario (like shops and names and descriptions of special items).

// You can create your own states, but you should give all of them numbers greater than
// or equal to 10.

beginscenarioscript;

variables;

body;

// This is the state that is called every time the scenario is loaded,
// even when a save file in the scenario is loaded. Some things that should go here:
//    Names and descriptions of special items.
//    Names and effects of custom special abilities.
beginstate LOAD_SCEN_STATE;

//Initialize Quests
	init_quest(0, "Find Brother Oakleaf", "Brother Oakleaf said he would be in the Order Preserve, and probably has a good idea of what's going on.");
	init_quest(1, "Meet with Oakleaf", "Brother Oakleaf told you to meet him in Relias, so that you can join him in his quest to find Ephesos.");
	init_quest(2, "Find Drakes in Preserve", "The citizens of Orrin told you that some drakes were spotted in the Order Preserve. It would definitely endear you to the citizens if you dealt with it.");
	init_quest(3, "Find Oakleaf... Again", "Brother Oakleaf told you he'd be at the Sanctum. You need to find him so you can help him find Ephesos.");	
	init_quest(10, "Prove yourself to Oakleaf", "Brother Oakleaf wants you to spread the Order's goodwill to all the towns in the valley. Then you can join him on his quest to find Ephesos.");

//Initialize Items
	init_special_item(0, "Oakleaf's Blessing", "Brother Oakleaf has confirmed you as a full member of the Order. Thus, you're entitled to a few privileges that only Order members have, and you're able to join Oakleaf in his quest to find Ephesos.");
	init_special_item(1, "Heartwood Key", "This wooden key unlocks the Order's artifact storage room.");

break;

// This is the state that is called only once at the very beginning of 
// the scenario. Some things that should go here:
//    The stuff in shops.
//    Creating horses and boats.
beginstate START_SCEN_STATE;
	// Initialize a few shops.
	
	// Shop 0 - armor
	add_item_to_shop(0,25,5);
	add_item_to_shop(0,26,2);
	add_item_to_shop(0,30,4);
	add_item_to_shop(0,31,2);
	add_item_to_shop(0,35,2);
	add_item_to_shop(0,121,5);
	add_item_to_shop(0,122,3);
	add_item_to_shop(0,126,2);
	add_item_to_shop(0,131,2);
	add_item_to_shop(0,111,5);
	add_item_to_shop(0,16,6);
	add_item_to_shop(0,136,4);
	add_item_to_shop(0,137,3);
	add_item_to_shop(0,141,2);
	
	// Shop 1 - weapons
	add_item_to_shop(1,45,5);
	add_item_to_shop(1,46,4);
	add_item_to_shop(1,50,6);
	add_item_to_shop(1,51,3);
	add_item_to_shop(1,55,3);
	add_item_to_shop(1,65,5);
	add_item_to_shop(1,66,3);
	add_item_to_shop(1,70,2);
	
	// Shop 2 - tools
	add_item_to_shop(2,170,500);
	add_item_to_shop(2,171,500);
	add_item_to_shop(2,172,30);
	add_item_to_shop(2,174,500);
	add_item_to_shop(2,177,500);
	
	// Shop 3 - missiles
	add_item_to_shop(3,86,500);
	add_item_to_shop(3,87,10);
	add_item_to_shop(3,92,10);
	add_item_to_shop(3,97,3);
	add_item_to_shop(3,101,30);
	add_item_to_shop(3,102,20);
	add_item_to_shop(3,107,10);

	// Shop 4 - potions
	add_item_to_shop(4,220,4);
	add_item_to_shop(4,221,3);
	add_item_to_shop(4,222,3);
	add_item_to_shop(4,223,2);

	// Shop 5 - food
	add_item_to_shop(5,4,500);
	add_item_to_shop(5,6,500);
	add_item_to_shop(5,7,500);
	add_item_to_shop(5,12,500); //deli sandwich
	add_item_to_shop(5,399,500); //cake
	add_item_to_shop(5,452,500); //plums
	add_item_to_shop(5,453,500); //oranges

	// Shop 6 - Brewery
	add_item_to_shop(6,166,3); //jug of cheap wine
	add_item_to_shop(6,414,8); //bottle of ale
	add_item_to_shop(6,415,8); //bottle of wine
	add_item_to_shop(6,418,2); //gremlin wine

	// Shop 7 - Orrin Bazaar
	add_item_to_shop(7,175,4); //Fine Lockpicks
	add_item_to_shop(7,207,1); //Gold Ring
	add_item_to_shop(7,178,3); //Fine First Aid Kit
	add_item_to_shop(7,180,4); //Nice Skin
	add_item_to_shop(7,92,1); //Yew Bow
	add_item_to_shop(7,66,2); //Iron Spear
	add_item_to_shop(7,26,5); //Leather Armor
	add_item_to_shop(7,285,1); //Wand of Lightning

	// Shop 8 - Slomar Farmers' Market
	add_item_to_shop(8,6,500); //Greens
	add_item_to_shop(8,5,500); //Mushrooms
	add_item_to_shop(8,397,500); //Pears
	add_item_to_shop(8,398,500); //Apples
	add_item_to_shop(8,450,500); //Peppers
	add_item_to_shop(8,451,500); //Radishes
	add_item_to_shop(8,452,500); //Plums
	add_item_to_shop(8,453,500); //Oranges
	add_item_to_shop(8,454,500); //Onions
	add_item_to_shop(8,214,5); //Healing Herbs
	add_item_to_shop(8,215,5); //Spiritual Herbs
	add_item_to_shop(8,216,5); //Energetic Herbs

	//Shop 9 - Delran's Forge
	add_item_to_shop(9,47,6); //Steel Dagger
	add_item_to_shop(9,35,3); //Poor Chain Mail
	add_item_to_shop(9,31,3); //Iron Studded Armor
	add_item_to_shop(9,32,1); //Steel Studded Armor
	add_item_to_shop(9,40,1); //Bronze Plate Mail
	add_item_to_shop(9,51,5); //Iron Short Sword
	add_item_to_shop(9,52,1); //Steel Short Sword
	add_item_to_shop(9,56,5); //Iron Long Sword
	add_item_to_shop(9,57,1); //Steel Long Sword
	add_item_to_shop(9,123,5); //Steel Buckler
	add_item_to_shop(9,128,5); //Steel Small Shield
	add_item_to_shop(9,66,5); //Iron Spear
	add_item_to_shop(9,71,1); //Iron Pike

	//Shop 10 - Skye's Priest Spells
	add_item_to_shop(10,3000,4); //Healing lvl4
	add_item_to_shop(10,3001,4); //Curing lvl4
	add_item_to_shop(10,3002,3); //War Blessing lvl3
	add_item_to_shop(10,3003,3); //Terror lvl3
	add_item_to_shop(10,3004,2); //Repel Spirit lvl2
	add_item_to_shop(10,3005,3); //Smite lvl3
	add_item_to_shop(10,3006,3); //Summon Shade lvl3
	add_item_to_shop(10,3007,3); //Enduring Barrier lvl3
	add_item_to_shop(10,3008,2); //Unshackle Mind lvl2
	add_item_to_shop(10,3009,3); //Move Mountains lvl3
	add_item_to_shop(10,3010,2); //Mass Healing lvl2
	add_item_to_shop(10,3011,2); //Mass Curing lvl2
	add_item_to_shop(10,3012,2); //Radiant Shield lvl2
	
	//Shop 11 - Nature Lore Skills
	add_item_to_shop(11,5016,3); //Nature Lore, 3 skills max
	add_item_to_shop(11,5024,3); //Pathfinder, 3 skills max

	//Shop 12 - Hemlock's Alchemy
	add_item_to_shop(12,4002,1); //Hasting Potion
	add_item_to_shop(12,4003,1); //Energy Potion
	add_item_to_shop(12,4004,1); //Strength Potion
	add_item_to_shop(12,4005,1); //Graymold Salve
	add_item_to_shop(12,4006,1); //Balm of Life
	add_item_to_shop(12,4007,1); //Healing Elixir
	add_item_to_shop(12,4008,1); //Hasting Elixir
	add_item_to_shop(12,4009,1); //Energy Elixir

	//Shop 13 - Mage Spells (Loranzo)
	add_item_to_shop(13,2000,4); //Bolt lvl4
	add_item_to_shop(13,2001,4); //Light lvl4
	add_item_to_shop(13,2002,3); //Call Beast lvl3
	add_item_to_shop(13,2003,3); //Spray acid lvl3
	add_item_to_shop(13,2004,3); //Haste lvl3
	add_item_to_shop(13,2005,3); //Slow lvl3
	add_item_to_shop(13,2006,3); //Ice Lances lvl3
	add_item_to_shop(13,2007,3); //Unlock Doors lvl3
	add_item_to_shop(13,2008,2); //Create illusions lvl2
	add_item_to_shop(13,2009,2); //Far Sight lvl2
	add_item_to_shop(13,2010,2); //Lightning Spray lvl2
	

break;

// This state is called every tick wherever the party is in the scenario.
// You can use the set_state
beginstate START_STATE;

break;

// Place your own states below. Give each a number at least 10.

beginstate 10; //State called when PC reads Oakleaf's note
	reset_dialog();
	add_dialog_str(0, "Adventurers, a terrible thing has occurred. The leader of our Order, Brother Ephesos, has disappeared, and we cannot locate him. We believe the Order of Flame is responsible. Something must be done, and I trust that you can help us.", 0);
	add_dialog_str(1,"You must leave and find me as quickly as possible. There's a secret passageway down there somewhere. I trust you can find it.", 0);
	add_dialog_str(2, "Oh yes, there's the matter of the gate. I've put a small spell into this paper that should be able to open it for you.", 0);
	add_dialog_str(3, "Once you escape, you can find me encamped on the Order Preserve. I can answer your questions then. Good luck, adventurers.", 0);
	add_dialog_str(4, "Brother Oakleaf", 15);
	run_dialog(1);
	if (get_flag(2,1) != 1) {
		put_sparkles_on_space(8,10,0,5);
		run_animation_sound(99);
		flip_terrain(8,10);
		force_instant_terrain_redraw();
		pause(10);
		message_dialog("Much to your annoyance, you now have more questions than answers as to what happened to you. Anyway, Brother Oakleaf can probably clear things up a bit.","You've just got to find him.");
		set_flag(2,1,1);
		print_str_color("The gate to your cell grinds open.", 2);
		toggle_quest(0,1);
		}
	else {
		print_str_color("Nothing happens. The scroll must've lost its magic.", 2);
		end();
		}
break;

beginstate 20; //Skyshard, detail
	if(is_town() == 1) {
		print_str_color("You cannot use the Skyshard while in a town.", 2);
		}
	else if(party_has_status(25) == 0) {
		play_sound(163);
		set_party_status(25,8,0);
		print_str_color("You rise into the air!",2); 
		}
	else  {
		print_str_color("You cannot use the Skyshard while already flying.",2);
		}
break;